//
// Created by root on 2019/9/26.
//

#ifndef AOA_HOTPLUG_H
#define AOA_HOTPLUG_H

#include "headerBase.h"
#include <thread>
#include <queue>
#include <mutex>

class HotPlug {
public:
    HotPlug();

    virtual ~HotPlug();

    void waitPhoneIn();

    void quit() {
        m_bQuit = true;
    }

    libusb_device *getDev();

    bool arrEvent();

    void setDev(libusb_device *dev);

    virtual void setDev(libusb_device *dev, int) {};

private:
    void _waitPhoneBlock();
    libusb_context *m_context;
    bool m_bQuit;
    std::thread m_thread;
    std::queue<libusb_device *> m_event;
    std::mutex m_lock;
};


#endif //AOA_HOTPLUG_H
